package com.example.demoserver.controller;

import com.example.demoserver.entity.InteAppstate;
import com.example.demoserver.service.InteAppstateService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;

import java.util.List;


@RequiredArgsConstructor
@Component
public class APPHealthState extends AbstractHealthIndicator {
    private final InteAppstateService inteAppstateService;

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        List<InteAppstate> list=  inteAppstateService.selectAll();
        builder.up()
                .withDetail("设备管理APP", list.get(0).getAppstate()==0?"启动":"关闭")
                .withDetail("生产管理APP", list.get(1).getAppstate()==0?"启动":"关闭")
                .withDetail("运营管理APP", list.get(2).getAppstate()==0?"启动":"关闭");
    }
}
